Skip to content

Fix #10605: Avoid mismatched constraints when prototypes are context … #10916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 26, 2020

…functions

Fixes #10605

@@ -632,7 +632,7 @@ object ProtoTypes {
normalize(et.resultType, pt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, adding the followIFT argument will only affect the fall through case and will be dropped for recursive calls. Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because all recursive normalize calls are against the same pt, which determined the value of followIFT.

Copy link
Contributor

@b-studios b-studios Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wondered whether the check can be inlined at 635 to

if iftp.exists && !defn.isContextFunctionType(pt) then ...

to avoid this additional argument. But this would not be a semantics preserving refactoring since the argument followIFT defaults to true for the next recursive call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, exactly.

val ptw = pt.widenExpr
necessarySubType(tpw, ptw) || tpw.isValueSubType(ptw) || viewExists(tp, pt)
val tpn = normalize(tp, pt, followIFT = !defn.isContextFunctionType(pt))
necessarySubType(tpn, pt) || tpn.isValueSubType(pt) || viewExists(tpn, pt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for so many questions on such a simple PR. But I noticed that you don't widen pt here anymore. Can't this change the result of comparing the types for other examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory it could, but in practice it did not. Conceptually, the correct thing is not to widen here, so unless we see an example where it causes a problem that should be the default.

@odersky odersky merged commit c9bf740 into scala:master Jan 6, 2021
@odersky odersky deleted the fix-#10605 branch January 6, 2021 12:41
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation hangs when trying to resolve a context function with multiple implicit parameters
3 participants